const { ethers } = require("ethers");
const fs = require("fs");

async function main() {
  // "http://192.168.206.1:8545"
  const provider = new ethers.JsonRpcProvider("http://192.168.206.1:8545");

  // // "http://47.120.6.18:8545"
  // const provider = new ethers.JsonRpcProvider("http://47.120.6.18:8545");
  const wallet = new ethers.Wallet(
    "0xa3771084eb23df7051bc2903e98c6b864f244ece5c8eb5a68eb310d496e3173c",
    provider
  );
  const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf-8");
  const binary = fs.readFileSync(
    "./SimpleStorage_sol_SimpleStorage.bin",
    "utf-8"
  );
  const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
  const contract = await contractFactory.deploy();
  console.log("Contract address: ", contract);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });
